
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Java并发 · tgor note</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="tgor">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-toc-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Java并发.html" />
    
    
    <link rel="prev" href="../category/java并发.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Me
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../category/微服务.html">
            
                <a href="../category/微服务.html">
            
                    
                    微服务
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Java-Spring/Feign.html">
            
                <a href="../Java-Spring/Feign.html">
            
                    
                    HTTP客户端Feign
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Java-其他库/限流.html">
            
                <a href="../Java-其他库/限流.html">
            
                    
                    限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../运维/Nginx限流.html">
            
                <a href="../运维/Nginx限流.html">
            
                    
                    限流Nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../Java-Spring/负载均衡.html">
            
                <a href="../Java-Spring/负载均衡.html">
            
                    
                    负载均衡
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../运维/Nginx负载均衡.html">
            
                <a href="../运维/Nginx负载均衡.html">
            
                    
                    负载均衡Nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../Java-其他库/熔断Hystrix.html">
            
                <a href="../Java-其他库/熔断Hystrix.html">
            
                    
                    熔断Hystrix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../Java-其他库/缓存.html">
            
                <a href="../Java-其他库/缓存.html">
            
                    
                    缓存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../Java-其他库/缓存.html">
            
                <a href="../Java-其他库/缓存.html#本地缓存">
            
                    
                    本地缓存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html">
            
                    
                    分布式缓存Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="../Java-其他库/分布式事务.html">
            
                <a href="../Java-其他库/分布式事务.html">
            
                    
                    分布式事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="../Java-其他库/分布式事务.html">
            
                <a href="../Java-其他库/分布式事务.html#事务消息">
            
                    
                    可靠事务消息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="../Java-Spring/业务监控.html">
            
                <a href="../Java-Spring/业务监控.html">
            
                    
                    业务监控
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.13" data-path="../Java-其他库/分布式定时作业.html">
            
                <a href="../Java-其他库/分布式定时作业.html">
            
                    
                    分布式作业调度ElasticJob
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.14" data-path="../Java-ORM/ORM.html">
            
                <a href="../Java-ORM/ORM.html">
            
                    
                    ORM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.15" data-path="../Java-其他库/分布式系统及CAP原理.html">
            
                <a href="../Java-其他库/分布式系统及CAP原理.html">
            
                    
                    分布式系统及CAP原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.16" data-path="../MQ/RabbitMQ笔记.html">
            
                <a href="../MQ/RabbitMQ笔记.html">
            
                    
                    消息驱动Rabbitmq
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../category/数据库.html">
            
                <a href="../category/数据库.html">
            
                    
                    数据库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Mysql/经典数据库设计案例.html">
            
                <a href="../Mysql/经典数据库设计案例.html">
            
                    
                    mysql设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../Mysql/Mysql事务与锁.html">
            
                <a href="../Mysql/Mysql事务与锁.html">
            
                    
                    mysql事务与锁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../Mysql/mysql数据类型.html">
            
                <a href="../Mysql/mysql数据类型.html">
            
                    
                    mysql数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../Mysql/mysql索引及查询.html">
            
                <a href="../Mysql/mysql索引及查询.html">
            
                    
                    mysql索引与查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../Mysql/mysql索引及查询.html">
            
                <a href="../Mysql/mysql索引及查询.html#查询语句设计准则">
            
                    
                    mysql查询语句设计准则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../Mysql/mysql性能测试.html">
            
                <a href="../Mysql/mysql性能测试.html">
            
                    
                    mysql性能测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../Mysql/mysql主从同步与读写分离.html">
            
                <a href="../Mysql/mysql主从同步与读写分离.html">
            
                    
                    mysql主从同步与读写分离
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../Java-Spring/SpringBoot事务注解@Transactional.html">
            
                <a href="../Java-Spring/SpringBoot事务注解@Transactional.html">
            
                    
                    Spring事务注解@Transactional
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../数据结构与算法/位运算应用实例.html">
            
                <a href="../数据结构与算法/位运算应用实例.html">
            
                    
                    位运算应用实例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../Mongodb-Client/morphia-API汇总.html">
            
                <a href="../Mongodb-Client/morphia-API汇总.html">
            
                    
                    morphia API汇总
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="../Mongodb-Client/mongo驱动连接.html">
            
                <a href="../Mongodb-Client/mongo驱动连接.html">
            
                    
                    mongodb驱动与连接
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="../Mongodb/mongodb-ObjectId实践.html">
            
                <a href="../Mongodb/mongodb-ObjectId实践.html">
            
                    
                    mongodb ObjectId实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="../Mongodb/mongodb角色权限.html">
            
                <a href="../Mongodb/mongodb角色权限.html">
            
                    
                    mongodb角色权限
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../category/java并发.html">
            
                <a href="../category/java并发.html">
            
                    
                    Java并发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.4.1" data-path="Java并发.html">
            
                <a href="Java并发.html">
            
                    
                    Java并发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="Java并发.html">
            
                <a href="Java并发.html#锁">
            
                    
                    Java并发之锁设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="Java并发.html">
            
                <a href="Java并发.html#synchronized">
            
                    
                    Java并发之synchronized
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="Java之Lock.html">
            
                <a href="Java之Lock.html#reentrantlock">
            
                    
                    Java Lock之ReentrantLock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="Java之Lock.html">
            
                <a href="Java之Lock.html#reentrantreadwritelock">
            
                    
                    Java Lock之ReentrantReadWriteLock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="Java之Future.html">
            
                <a href="Java之Future.html">
            
                    
                    Java Future
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="Java之Future.html">
            
                <a href="Java之Future.html#futuretask">
            
                    
                    Java Future之FutureTask
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="Java之Future.html">
            
                <a href="Java之Future.html#completablefuture">
            
                    
                    Java Future之CompletableFuture
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="Java之Future.html">
            
                <a href="Java之Future.html#forkjointask">
            
                    
                    Java Future之ForkJoinTask
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="Java之Thread.html">
            
                <a href="Java之Thread.html">
            
                    
                    Java Thread
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../category/redis.html">
            
                <a href="../category/redis.html">
            
                    
                    Redis
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#集群">
            
                    
                    Redis集群
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#消息订阅">
            
                    
                    Redis消息订阅
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#lua">
            
                    
                    Redis Lua脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#配置汇总">
            
                    
                    Redis配置汇总
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../category/运维.html">
            
                <a href="../category/运维.html">
            
                    
                    运维
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../运维/Linux常用操作汇总.html">
            
                <a href="../运维/Linux常用操作汇总.html">
            
                    
                    Linux常用操作汇总
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../运维/阿里云笔记.html">
            
                <a href="../运维/阿里云笔记.html">
            
                    
                    阿里云笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../category/nginx.html">
            
                <a href="../category/nginx.html">
            
                    
                    Nginx
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../运维/Nginx学习笔记.html">
            
                <a href="../运维/Nginx学习笔记.html">
            
                    
                    Nginx基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../运维/Nginx负载均衡.html">
            
                <a href="../运维/Nginx负载均衡.html">
            
                    
                    Nginx负载均衡
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../运维/Nginx限流.html">
            
                <a href="../运维/Nginx限流.html">
            
                    
                    Nginx限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../运维/Nginx学习笔记.html">
            
                <a href="../运维/Nginx学习笔记.html#六、其他">
            
                    
                    Nginx客户端辅助技巧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../category/容器化.html">
            
                <a href="../category/容器化.html">
            
                    
                    容器化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../Docker/docker笔记.html">
            
                <a href="../Docker/docker笔记.html">
            
                    
                    Docker学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../Docker/docker笔记.html">
            
                <a href="../Docker/docker笔记.html#基础操作">
            
                    
                    Docker基础操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../Docker/docker笔记.html">
            
                <a href="../Docker/docker笔记.html#dockerfile">
            
                    
                    DockerFile
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../category/Web.html">
            
                <a href="../category/Web.html">
            
                    
                    Web
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../运维/Http入坑Https笔记.html">
            
                <a href="../运维/Http入坑Https笔记.html">
            
                    
                    Http入坑Https笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../Web/阿里云OSS.html">
            
                <a href="../Web/阿里云OSS.html">
            
                    
                    OSS
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../category/java基础.html">
            
                <a href="../category/java基础.html">
            
                    
                    Java基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="Java基础.html">
            
                <a href="Java基础.html#jvm">
            
                    
                    JVM基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="Java基础.html">
            
                <a href="Java基础.html#语法糖">
            
                    
                    Java语法糖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="Java基础.html">
            
                <a href="Java基础.html#数据结构">
            
                    
                    Java数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="Java8函数式编程.html">
            
                <a href="Java8函数式编程.html">
            
                    
                    java8函数式编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="ArrayList源码分析.html">
            
                <a href="ArrayList源码分析.html">
            
                    
                    JDK源码分析ArrayList
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="HashMap源码分析.html">
            
                <a href="HashMap源码分析.html">
            
                    
                    JDK源码分析HashMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="Java注解.html">
            
                <a href="Java注解.html">
            
                    
                    Java注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="Timsort排序算法.html">
            
                <a href="Timsort排序算法.html">
            
                    
                    Timsort排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.9" data-path="插入排序分析与Java实现.html">
            
                <a href="插入排序分析与Java实现.html">
            
                    
                    插入排序分析与Java实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../category/工具与规范.html">
            
                <a href="../category/工具与规范.html">
            
                    
                    工具与规范
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../工具/Maven使用技巧汇总.html">
            
                <a href="../工具/Maven使用技巧汇总.html">
            
                    
                    Maven使用技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../编码规范/Java编码规范.html">
            
                <a href="../编码规范/Java编码规范.html">
            
                    
                    Java编码规范
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../category/OLAP.html">
            
                <a href="../category/OLAP.html">
            
                    
                    OLAP
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../数据处理/storm学习笔记.html">
            
                <a href="../数据处理/storm学习笔记.html">
            
                    
                    流式计算Storm学习笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../category/数据运营.html">
            
                <a href="../category/数据运营.html">
            
                    
                    数据运营
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../数据运营/增长黑客数据运营.html">
            
                <a href="../数据运营/增长黑客数据运营.html">
            
                    
                    增长黑客-数据运营
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../category/前端技术栈.html">
            
                <a href="../category/前端技术栈.html">
            
                    
                    前端技术栈
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../前端/JavaScript设计模式.html">
            
                <a href="../前端/JavaScript设计模式.html">
            
                    
                    JavaScript设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../前端/html相对路径与绝对路径.html">
            
                <a href="../前端/html相对路径与绝对路径.html">
            
                    
                    Html相对路径与绝对路径
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../前端/微信小程序学习笔记.html">
            
                <a href="../前端/微信小程序学习笔记.html">
            
                    
                    微信小程序学习笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../category/个人.html">
            
                <a href="../category/个人.html">
            
                    
                    个人
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../个人/简历.html">
            
                <a href="../个人/简历.html">
            
                    
                    简历
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Java并发</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="java&#x5E76;&#x53D1;">Java&#x5E76;&#x53D1;</h1>
<h1 id="&#x5185;&#x5B58;&#x6A21;&#x578B;">&#x5185;&#x5B58;&#x6A21;&#x578B;</h1>
<p><img src="assets/1576933202043.png" alt="1576933202043"></p>
<p>Java&#x5185;&#x5B58;&#x6A21;&#x578B;&#x5206;&#x4E3A;&#x4E86;<strong>&#x4E3B;&#x5185;&#x5B58;</strong>&#x548C;<strong>&#x5DE5;&#x4F5C;&#x5185;&#x5B58;</strong></p>
<ul>
<li>&#x5171;&#x4EAB;&#x5BF9;&#x8C61;&#xFF0C;&#x90FD;&#x662F;&#x5B58;&#x50A8;&#x4E3B;&#x5185;&#x5B58;</li>
<li>&#x7EBF;&#x7A0B;&#x4F7F;&#x7528;&#x5BF9;&#x8C61;&#x65F6;&#xFF0C;&#x4F1A;&#x8BFB;&#x4E00;&#x6B21;&#x4E3B;&#x5185;&#x5B58;&#xFF0C;&#x5E76;&#x5B58;&#x4E00;&#x4EFD;&#x526F;&#x672C;&#x81EA;&#x5DF1;&#x7684;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;</li>
<li>&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#xFF0C;&#x66F4;&#x65B0;&#x5230;&#x4E3B;&#x5185;&#x5B58;</li>
</ul>
<p>&#x5173;&#x4E8E;volatile&#x4E0E;synchronized </p>
<ul>
<li><p><strong>volatile</strong> - &#x4FDD;&#x8BC1;&#x8BFB;&#x5199;&#x7684;&#x90FD;&#x662F;&#x4E3B;&#x5185;&#x5B58;&#x53D8;&#x91CF;&#x3002;</p>
</li>
<li><p><strong>synchronized</strong> - &#x4FDD;&#x8BC1;&#x5728;&#x5757;&#x5F00;&#x59CB;&#x65F6;&#xFF0C;&#x90FD;&#x540C;&#x6B65;&#x4E3B;&#x5185;&#x5B58;&#x503C;&#x5230;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#xFF0C;&#x800C;&#x5FEB;&#x7ED3;&#x675F;&#x65F6;&#xFF0C;&#x5C06;&#x5DE5;&#x4F5C;&#x5185;&#x5B58;&#x540C;&#x6B65;&#x4F1A;&#x4E3B;&#x5185;&#x5B58;&#x3002;</p>
</li>
</ul>
<h1 id="concurrent3&#x5927;&#x6838;&#x5FC3;&#x63A5;&#x53E3;">Concurrent3&#x5927;&#x6838;&#x5FC3;&#x63A5;&#x53E3;</h1>
<ul>
<li>Future&#xFF1A;<a href="Java&#x4E4B;Future.html">&#x5F02;&#x6B65;&#x4EFB;&#x52A1;</a></li>
<li>Lock&#xFF1A;<a href="Java&#x4E4B;Lock.html">&#x9501;</a></li>
<li>Executor&#xFF1A;<a href="Java&#x4E4B;Executor.md">&#x7EBF;&#x7A0B;&#x6C60;&#x6846;&#x67B6;</a></li>
<li>Thread&#xFF1A;<a href="Java&#x4E4B;Thread.html">&#x7EBF;&#x7A0B;</a></li>
</ul>
<h1 id="&#x9501;">&#x9501;</h1>
<h2 id="&#x7C92;&#x5EA6;">&#x7C92;&#x5EA6;</h2>
<p>Java&#x4E2D;&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x90FD;&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x9501;&#xFF0C;&#x800C;&#x5BF9;&#x8C61;&#x5C31;&#x51B3;&#x5B9A;&#x4E86;&#x9501;&#x7684;&#x7C92;&#x5EA6;&#x5927;&#x5C0F;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x5B9E;&#x4F8B;&#x540C;&#x6B65;&#x65B9;&#x6CD5;&#xFF0C;&#x9501;&#x662F;&#x5F53;&#x524D;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Test</span> </span>{    
    <span class="hljs-function"><span class="hljs-keyword">public</span> syncronized <span class="hljs-keyword">void</span> <span class="hljs-title">write</span><span class="hljs-params">(<span class="hljs-keyword">boolean</span> flag)</span> </span>{
            xxxxx
     }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">synchronized</span> <span class="hljs-keyword">void</span> <span class="hljs-title">read</span><span class="hljs-params">()</span> </span>{
        xxxxx
    }
}

Test test = <span class="hljs-keyword">new</span> Test();
<span class="hljs-comment">//&#x9501;&#x7C92;&#x5EA6;&#x4E3A;test&#x5B9E;&#x4F8B;</span>
test.write(<span class="hljs-keyword">false</span>);

Test t1 = <span class="hljs-keyword">new</span> Test();
Test t2 = <span class="hljs-keyword">new</span> Test();

<span class="hljs-keyword">new</span> Thread(()-&gt;{
    t1.write()
}).run();

<span class="hljs-keyword">new</span> Thread(()-&gt;{
    <span class="hljs-comment">//&#x4E0D;&#x80FD;&#x8BBF;&#x95EE;&#xFF0C;&#x56E0;&#x4E3A;&#x9501;&#x5B9A;&#x5BF9;&#x8C61;&#x90FD;&#x662F;t1</span>
    t1.read()
}).run();

<span class="hljs-keyword">new</span> Thread(()-&gt;{
    <span class="hljs-comment">//&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;</span>
    t2.write()
}).run();
</code></pre>
<p>&#x5BF9;&#x4E8E;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#xFF0C;&#x9501;&#x662F;TestStatic.class&#x5BF9;&#x8C61;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestStatic</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> syncronized <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">write</span><span class="hljs-params">(<span class="hljs-keyword">boolean</span> flag)</span> </span>{
        xxxxx
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">synchronized</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">read</span><span class="hljs-params">()</span> </span>{
        xxxxx
    }
}

<span class="hljs-comment">//&#x9501;&#x7C92;&#x5EA6;TestStatic.class</span>
TestStatic.write(<span class="hljs-keyword">false</span>)
</code></pre>
<p>&#x5BF9;&#x4E8E;&#x540C;&#x6B65;&#x4EE3;&#x7801;&#x5757;&#xFF0C;&#x9501;&#x662F;Synchronized&#x62EC;&#x53F7;&#x91CC;&#x9762;&#x914D;&#x7F6E;&#x7684;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> List&lt;String&gt; list;

<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">add</span><span class="hljs-params">(String a)</span></span>{
    <span class="hljs-comment">//&#x9501;&#x5B9A;&#x7C92;&#x5EA6;&#x4E3A;list</span>
    <span class="hljs-keyword">synchronized</span>(list){
        list.add(a);
    }
}
</code></pre>
<h2 id="&#x6309;&#x7C92;&#x5EA6;&#x5206;&#x7C7B;">&#x6309;&#x7C92;&#x5EA6;&#x5206;&#x7C7B;</h2>
<ol>
<li>&#x72EC;&#x5360;&#x9501;&#xFF1A;&#x53EA;&#x6709;&#x4E00;&#x6761;&#x7EBF;&#x7A0B;&#x72EC;&#x5360;</li>
<li>&#x5206;&#x62C6;&#x9501;&#xFF1A;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x4E2D;&#x591A;&#x4E2A;&#x53D8;&#x91CF;&#x591A;&#x4E2A;&#x9501;</li>
<li>&#x5206;&#x79BB;&#x9501;&#xFF1A;&#x4F8B;&#x5982;concurrentHashMap&#xFF0C;&#x5206;&#x6BB5;&#x4E0A;&#x9501;</li>
</ol>
<h2 id="synchronized">synchronized</h2>
<p>&#x7279;&#x70B9;</p>
<ul>
<li>&#x5173;&#x952E;&#x5B57;&#x8BED;&#x6CD5;&#x7CD6;</li>
<li>&#x9690;&#x5F0F;&#x4E0A;&#x9501;</li>
<li>&#x7EBF;&#x7A0B;&#x72EC;&#x5360;</li>
</ul>
<h3 id="&#x8F7B;&#x91CF;&#x7EA7;&#x9501;&#x53CA;&#x81A8;&#x80C0;&#x6D41;&#x7A0B;">&#x8F7B;&#x91CF;&#x7EA7;&#x9501;&#x53CA;&#x81A8;&#x80C0;&#x6D41;&#x7A0B;</h3>
<p><img src="assets/1577069987998.png" alt="1577069987998"></p>
<p>&#x5173;&#x952E;&#x903B;&#x8F91;&#xFF1A;&#x901A;&#x8FC7;<strong>CAS</strong>&#x539F;&#x5B50;&#x64CD;&#x4F5C;&#xFF0C;&#x4FEE;&#x6539;&#x5BF9;&#x8C61;&#x7684;<strong>Mark Word</strong>&#xFF0C;&#x5982;&#x679C;&#x6210;&#x529F;&#xFF0C;&#x4E0A;&#x8F7B;&#x91CF;&#x7EA7;&#x9501;&#xFF0C;&#x5426;&#x5219;&#x4E0A;&#x91CD;&#x91CF;&#x9501;&#xFF0C;&#x5E76;&#x7EBF;&#x7A0B;&#x963B;&#x585E;</p>
<h2 id="reentrantlock">ReentrantLock</h2>
<p><a href="Java&#x4E4B;Lock.html#reentrantlock">ReentrantLock&#x57FA;&#x7840;&#x53CA;&#x6E90;&#x7801;&#x5206;&#x6790;</a></p>
<h2 id="reentrantreadwritelock">ReentrantReadWriteLock</h2>
<p><a href="Java&#x4E4B;Lock.html#reentrantreadwritelock">ReentrantReadWriteLock&#x57FA;&#x7840;&#x53CA;&#x6E90;&#x7801;&#x5206;&#x6790;</a></p>
<hr>
<h1 id="&#x7EBF;&#x7A0B;&#x5B89;&#x5168;">&#x7EBF;&#x7A0B;&#x5B89;&#x5168;</h1>
<p>&#x6700;&#x597D;&#x7684;&#x89E3;&#x91CA;&#xFF1A;<strong>&#x5982;&#x679C;&#x4F60;&#x7684;&#x4EE3;&#x7801;&#x5728;&#x591A;&#x7EBF;&#x7A0B;&#x4E0B;&#x6267;&#x884C;&#x548C;&#x5728;&#x5355;&#x7EBF;&#x7A0B;&#x4E0B;&#x6267;&#x884C;&#x6C38;&#x8FDC;&#x90FD;&#x80FD;&#x83B7;&#x5F97;&#x4E00;&#x6837;&#x7684;&#x7ED3;&#x679C;&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x7684;&#x4EE3;&#x7801;&#x5C31;&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;</strong></p>
<h2 id="&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7EA7;&#x522B;">&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7EA7;&#x522B;</h2>
<h3 id="&#x4E0D;&#x53EF;&#x53D8;immutable">&#x4E0D;&#x53EF;&#x53D8;Immutable</h3>
<p>&#x50CF;String&#x3001;Integer&#x3001;Long&#x8FD9;&#x4E9B;&#xFF0C;&#x90FD;&#x662F;final&#x7C7B;&#x578B;&#x7684;&#x7C7B;&#xFF0C;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x90FD;&#x6539;&#x53D8;&#x4E0D;&#x4E86;&#x5B83;&#x4EEC;&#x7684;&#x503C;&#xFF0C;&#x8981;&#x6539;&#x53D8;&#x9664;&#x975E;&#x65B0;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#xFF0C;&#x56E0;&#x6B64;&#x8FD9;&#x4E9B;&#x4E0D;&#x53EF;&#x53D8;&#x5BF9;&#x8C61;&#x4E0D;&#x9700;&#x8981;&#x4EFB;&#x4F55;&#x540C;&#x6B65;&#x624B;&#x6BB5;&#x5C31;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x591A;&#x7EBF;&#x7A0B;&#x73AF;&#x5883;&#x4E0B;&#x4F7F;&#x7528;</p>
<p><strong>&#x4F46;&#x5E76;&#x4E0D;&#x4EE3;&#x8868;&#x4E0D;&#x53EF;&#x53D8;&#x7C7B;&#x7684;&#x5BF9;&#x8C61;&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;</strong></p>
<p>&#x4F8B;&#x5982;Integer&#x4E3A;&#x4E0D;&#x53EF;&#x53D8;&#x7C7B;&#x578B;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">final</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Integer</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Number</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Comparable</span>&lt;<span class="hljs-title">Integer</span>&gt; </span>{
}

<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> Integer target = <span class="hljs-number">0</span>;

<span class="hljs-comment">//&#x901A;&#x8FC7;&#x591A;&#x6761;&#x7EBF;&#x7A0B;&#x5E76;&#x53D1;&#x9012;&#x589E;target&#x7684;&#x503C;</span>
Thread thread = <span class="hljs-keyword">new</span> Thread(() -&gt; { 
    <span class="hljs-comment">//&#x91CD;&#x65B0;&#x4E3A;target&#x8D4B;&#x503C;&#xFF0C;&#x7B49;&#x540C;&#x65B0;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;target&#xFF0C;&#x540C;&#x6837;&#x975E;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;</span>
    target = target + <span class="hljs-number">1</span>;
});
</code></pre>
<p>&#x5E38;&#x89C1;final&#x7C7B;</p>
<ul>
<li>public final class <strong>Boolean</strong></li>
<li>public final class <strong>Byte</strong></li>
<li>public final class <strong>Character</strong></li>
<li>public final class <strong>Double</strong></li>
<li>public final class <strong>Float</strong></li>
<li>public final class <strong>Integer</strong></li>
<li>public final class <strong>Long</strong></li>
<li>public final class <strong>Math</strong></li>
<li>public final class <strong>Short</strong></li>
<li>public final class <strong>String</strong></li>
<li>public final class <strong>StringBuffer</strong></li>
<li>public final class <strong>StringBuilder</strong></li>
<li>public final class <strong>System</strong></li>
<li>public final class <strong>Void</strong></li>
</ul>
<h3 id="&#x7EDD;&#x5BF9;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;">&#x7EDD;&#x5BF9;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;</h3>
<p>&#x4E0D;&#x7BA1;&#x8FD0;&#x884C;&#x65F6;&#x73AF;&#x5883;&#x5982;&#x4F55;&#xFF0C;&#x8C03;&#x7528;&#x8005;&#x90FD;&#x4E0D;&#x9700;&#x8981;&#x989D;&#x5916;&#x7684;&#x540C;&#x6B65;&#x63AA;&#x65BD;&#x3002;&#x8981;&#x505A;&#x5230;&#x8FD9;&#x4E00;&#x70B9;&#x901A;&#x5E38;&#x9700;&#x8981;&#x4ED8;&#x51FA;&#x8BB8;&#x591A;&#x989D;&#x5916;&#x7684;&#x4EE3;&#x4EF7;&#xFF0C;Java&#x4E2D;&#x6807;&#x6CE8;&#x81EA;&#x5DF1;&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x7C7B;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x7EDD;&#x5927;&#x591A;&#x6570;&#x90FD;&#x4E0D;&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#xFF0C;&#x4E0D;&#x8FC7;&#x7EDD;&#x5BF9;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x7C7B;&#xFF0C;Java&#x4E2D;&#x4E5F;&#x6709;&#xFF0C;&#x6BD4;&#x65B9;&#x8BF4;CopyOnWriteArrayList&#x3001;CopyOnWriteArraySet</p>
<h3 id="&#x76F8;&#x5BF9;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;">&#x76F8;&#x5BF9;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;</h3>
<p>&#x76F8;&#x5BF9;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x4E5F;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x901A;&#x5E38;&#x610F;&#x4E49;&#x4E0A;&#x6240;&#x8BF4;&#x7684;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#xFF0C;&#x50CF;Vector&#x8FD9;&#x79CD;&#xFF0C;add&#x3001;remove&#x65B9;&#x6CD5;&#x90FD;&#x662F;&#x539F;&#x5B50;&#x64CD;&#x4F5C;&#xFF0C;&#x4E0D;&#x4F1A;&#x88AB;&#x6253;&#x65AD;&#xFF0C;&#x4F46;&#x4E5F;&#x4EC5;&#x9650;&#x4E8E;&#x6B64;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x4E2A;&#x7EBF;&#x7A0B;&#x5728;&#x904D;&#x5386;&#x67D0;&#x4E2A;Vector&#x3001;&#x6709;&#x4E2A;&#x7EBF;&#x7A0B;&#x540C;&#x65F6;&#x5728;add&#x8FD9;&#x4E2A;Vector&#xFF0C;99%&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x90FD;&#x4F1A;&#x51FA;&#x73B0;ConcurrentModificationException&#xFF0C;&#x4E5F;&#x5C31;&#x662F;<strong>fail-fast&#x673A;&#x5236;</strong>&#x3002;</p>
<p><strong>&#x4E24;&#x79CD;&#x60C5;&#x51B5;&#xFF1A;</strong></p>
<p>&#x5982;&#x679C;&#x6709;&#x4E2A;&#x7EBF;&#x7A0B;&#x5728;&#x904D;&#x5386;&#x67D0;&#x4E2A;Vector&#x3001;&#x6709;&#x4E2A;&#x7EBF;&#x7A0B;&#x540C;&#x65F6;&#x5728;add&#x8FD9;&#x4E2A;Vector&#xFF0C;&#x62A5;&#x9519;ConcurrentModificationException</p>
<p>&#x5982;&#x679C;&#x6709;&#x4E2A;&#x7EBF;&#x7A0B;remove&#x8FD9;&#x4E2A;vector&#xFF0C;&#x6709;&#x4E2A;&#x7EBF;&#x7A0B;&#x5728;get&#xFF0C;&#x62A5;&#x9519;&#x8D85;&#x51FA;&#x7D22;&#x5F15;&#x8303;&#x56F4;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">VectorUnsafe</span> </span>{    
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> Vector&lt;Integer&gt; vector = <span class="hljs-keyword">new</span> Vector&lt;Integer&gt;();    
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{        
        <span class="hljs-keyword">while</span> (<span class="hljs-keyword">true</span>) {            
            <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">10</span>; i++) {                
                vector.add(i);            
            }            
            Thread removeThread = <span class="hljs-keyword">new</span> Thread(<span class="hljs-keyword">new</span> Runnable() {                
                <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span><span class="hljs-params">()</span> </span>{                    
                    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; vector.size(); i++) {                        
                        vector.remove(i);                    
                    }                
                }            
            });            
            Thread getThread = <span class="hljs-keyword">new</span> Thread(<span class="hljs-keyword">new</span> Runnable() {                
                <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span><span class="hljs-params">()</span> </span>{                    
                    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; vector.size()&#x4E0E;; i++) {
                        <span class="hljs-comment">//&#x62A5;&#x9519;ArrayIndexOutOfBoundsException</span>
                        <span class="hljs-comment">//&#x6309;&#x7167;&#x76F4;&#x89C9;&#x5206;&#x6790;&#xFF0C;get&#x65B9;&#x6CD5;&#x5F85;sync&#xFF0C;&#x800C;&#x4E14;&#x9501;&#x7684;&#x7C92;&#x5EA6;&#x90FD;&#x662F;vector&#x5B9E;&#x4F8B;&#xFF0C;&#x5E94;&#x8BE5;&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x3002;</span>
                        <span class="hljs-comment">//&#x867D;&#x7136;size()&#x4E0E;get()&#x5404;&#x81EA;&#x90FD;&#x662F;&#x540C;&#x6B65;&#x65B9;&#x6CD5;&#xFF0C;&#x4F46;&#x5728;&#x5916;&#x90E8;&#x8C03;&#x7528;&#x65F6;&#xFF0C;&#x5219;&#x6CA1;&#x6709;&#x540C;&#x6B65;&#xFF0C;&#x975E;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#xFF0C;</span>
                        <span class="hljs-comment">//&#x7B26;&#x5408;&#x5E76;&#x53D1;&#x8BBE;&#x8BA1;&#x539F;&#x5219;2&#xFF0C;&#x907F;&#x514D;&#x8FC7;&#x5EA6;&#x540C;&#x6B65;&#xFF1A;&#x5C3D;&#x91CF;&#x4EA4;&#x7531;&#x5916;&#x90E8;&#x540C;&#x6B65;</span>
                        vector.get(i);                    
                    }                
                }            
            });            
            removeThread.start();            
            getThread.start();            

            <span class="hljs-keyword">while</span> (Thread.activeCount() &gt; <span class="hljs-number">20</span>) ;        
        }    
    }
}
</code></pre>
<h3 id="&#x7EBF;&#x7A0B;&#x975E;&#x5B89;&#x5168;">&#x7EBF;&#x7A0B;&#x975E;&#x5B89;&#x5168;</h3>
<p>&#x8FD9;&#x4E2A;&#x5C31;&#x6CA1;&#x4EC0;&#x4E48;&#x597D;&#x8BF4;&#x7684;&#x4E86;&#xFF0C;ArrayList&#x3001;LinkedList&#x3001;HashMap&#x7B49;&#x90FD;&#x662F;&#x7EBF;&#x7A0B;&#x975E;&#x5B89;&#x5168;&#x7684;&#x7C7B;</p>
<h1 id="&#x5E76;&#x53D1;&#x8BBE;&#x8BA1;&#x539F;&#x5219;">&#x5E76;&#x53D1;&#x8BBE;&#x8BA1;&#x539F;&#x5219;</h1>
<h2 id="&#x540C;&#x6B65;&#x8BBF;&#x95EE;&#x5171;&#x4EAB;&#x6570;&#x636E;">&#x540C;&#x6B65;&#x8BBF;&#x95EE;&#x5171;&#x4EAB;&#x6570;&#x636E;</h2>
<h2 id="&#x907F;&#x514D;&#x8FC7;&#x5EA6;&#x540C;&#x6B65;">&#x907F;&#x514D;&#x8FC7;&#x5EA6;&#x540C;&#x6B65;</h2>
<p>&#x539F;&#x5219;</p>
<ol>
<li>&#x5E94;&#x8BE5;&#x5728;&#x540C;&#x6B65;&#x533A;&#x57DF;&#x5185;&#x505A;&#x5C3D;&#x91CF;&#x53EF;&#x80FD;&#x5C11;&#x7684;&#x5DE5;&#x4F5C;&#xFF1B;</li>
<li>&#x5C3D;&#x91CF;&#x4E0D;&#x8981;&#x5728;&#x5185;&#x90E8;&#x540C;&#x6B65;&#xFF0C;&#x8BA9;&#x5BA2;&#x6237;&#x5728;&#x5FC5;&#x8981;&#x7684;&#x65F6;&#x5019;&#x4ECE;&#x5916;&#x90E8;&#xFF1B;</li>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x53EF;&#x53D8;&#x7684;&#x7C7B;&#x8981;&#x5E76;&#x53D1;&#x4F7F;</li>
<li>&#x5982;&#x679C;&#x5185;&#x90E8;&#x540C;&#x6B65;&#x7C7B;&#xFF0C;&#x901A;&#x8FC7;&#x5206;&#x62C6;&#x9501;&#x3001;&#x5206;&#x79BB;&#x9501;&#x3001;&#x975E;&#x963B;&#x585E;&#x7B49;&#x624B;&#x6BB5;&#x63D0;&#x9AD8;&#x5E76;&#x53D1;&#x6027;&#x80FD;</li>
<li>&#x5343;&#x4E07;&#x4E0D;&#x8981;&#x4ECE;&#x540C;&#x6B65;&#x533A;&#x57DF;&#x5185;&#x90E8;&#x8C03;&#x7528;&#x5916;&#x90E8;&#x65B9;&#x6CD5;</li>
</ol>
<h2 id="&#x5E76;&#x53D1;&#x5DE5;&#x5177;&#x4F18;&#x5148;&#x4E8E;wait&#x548C;notify">&#x5E76;&#x53D1;&#x5DE5;&#x5177;&#x4F18;&#x5148;&#x4E8E;wait&#x548C;notify</h2>
<p>&#x7528;&#x66F4;&#x9AD8;&#x7EA7;&#x7684;&#x5E76;&#x53D1;&#x5DE5;&#x5177;&#x6765;&#x4EE3;&#x66FF;wait&#x548C;notify</p>
<p>&#x53C2;&#x8003;<a href="#&#x5E76;&#x53D1;&#x5DE5;&#x5177;">java.util.concurrent</a></p>
<h2 id="&#x5E76;&#x53D1;&#x5DE5;&#x5177;">&#x5E76;&#x53D1;&#x5DE5;&#x5177;</h2>
<p>java.util.concurrent&#x5206;&#x4E3A;3&#x7C7B;</p>
<ul>
<li>Executor Framework</li>
<li>Collection</li>
<li>&#x540C;&#x6B65;&#x5668;Synchronizer</li>
</ul>
<h1 id="&#x9644;&#x5F55;">&#x9644;&#x5F55;</h1>
<h2 id="&#x6570;&#x636E;&#x53C2;&#x8003;">&#x6570;&#x636E;&#x53C2;&#x8003;</h2>
<h3 id="&#x540D;&#x8BCD;&#x89E3;&#x91CA;">&#x540D;&#x8BCD;&#x89E3;&#x91CA;</h3>
<ul>
<li>UV&#xFF1A;&#x8BBF;&#x95EE;&#x7F51;&#x7AD9;&#x7684;&#x4EBA;&#x5934;&#x6570;&#xFF0C;Unique Visitor,&#x8BBF;&#x95EE;&#x60A8;&#x7F51;&#x7AD9;&#x7684;&#x4E00;&#x53F0;&#x7535;&#x8111;&#x5BA2;&#x6237;&#x7AEF;&#x4E3A;&#x4E00;&#x4E2A;&#x8BBF;&#x5BA2;&#x3002;00:00-24:00&#x5185;&#x76F8;&#x540C;&#x7684;&#x5BA2;&#x6237;&#x7AEF;&#x53EA;&#x4F1A;&#x88AB;&#x8BA1;&#x7B97;&#x4E00;&#x6B21;</li>
<li>PV&#xFF1A;&#x70B9;&#x51FB;&#x91CF;&#x3001;&#x6D4F;&#x89C8;&#x91CF;</li>
<li>TPS=transactions per second</li>
<li>QPS=queries per second</li>
<li>RPS=requests per second</li>
</ul>
<p>QPS&#x8BA1;&#x7B97;&#x516C;&#x5F0F;</p>
<p>&#x539F;&#x7406;&#xFF1A;&#x6BCF;&#x5929;80%&#x7684;&#x8BBF;&#x95EE;&#x96C6;&#x4E2D;&#x5728;20%&#x7684;&#x65F6;&#x95F4;&#x91CC;&#xFF0C;&#x8FD9;20%&#x65F6;&#x95F4;&#x53EB;&#x505A;&#x5CF0;&#x503C;&#x65F6;&#x95F4;
&#x516C;&#x5F0F;&#xFF1A;( &#x603B;PV&#x6570; <em> 80% ) / ( &#x6BCF;&#x5929;&#x79D2;&#x6570; </em> 20% ) = &#x5CF0;&#x503C;&#x65F6;&#x95F4;&#x6BCF;&#x79D2;&#x8BF7;&#x6C42;&#x6570;(QPS)
&#x673A;&#x5668;&#xFF1A;&#x5CF0;&#x503C;&#x65F6;&#x95F4;&#x6BCF;&#x79D2;QPS / &#x5355;&#x53F0;&#x673A;&#x5668;&#x7684;QPS = &#x9700;&#x8981;&#x7684;&#x673A;&#x5668;</p>
<h3 id="&#x4F30;&#x7B97;">&#x4F30;&#x7B97;</h3>
<table>
<thead>
<tr>
<th>&#x5E38;&#x89C4;&#x4E1A;&#x52A1;</th>
<th>&#x6570;&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td>uv</td>
<td>14-20w</td>
</tr>
<tr>
<td>&#x8425;&#x9500;&#x4E1A;&#x52A1;PV</td>
<td>40-80w</td>
</tr>
<tr>
<td>&#x5B9E;&#x9645;&#x8BF7;&#x6C42;&#x6570;</td>
<td>120-240w</td>
</tr>
<tr>
<td>&#x5E38;&#x89C4;&#x4E1A;&#x52A1;qps</td>
<td>&#x5CF0;&#x503C;92 = <code>(200w * 0.8) / (86400 *0.2)</code></td>
</tr>
</tbody>
</table>
<p>&#x5E38;&#x89C4;&#x62A2;&#x8D2D;&#x4E1A;&#x52A1;&#xFF08;&#x96F6;&#x5143;&#x8D2D;&#x3001;&#x62BD;&#x5956;&#x3001;&#x7279;&#x6743;&#x6807;&#xFF09;</p>
<p>&#x6839;&#x636E;&#x7ECF;&#x9A8C;&#xFF0C;&#x6D41;&#x91CF;&#x90FD;&#x96C6;&#x4E2D;&#x5728;&#x5934;5&#x79D2;</p>
<table>
<thead>
<tr>
<th>&#x5E38;&#x89C4;&#x62A2;&#x8D2D;&#x4E1A;&#x52A1;</th>
<th>&#x89C4;&#x6A21;</th>
<th>&#x7406;&#x8BBA;&#x652F;&#x6491;</th>
<th>&#x5B9E;&#x6218;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x62A2;&#x8D2D;&#x4E1A;&#x52A1;&#x53C2;&#x4E0E;&#x4EBA;&#x6570;</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>&#x5B9E;&#x9645;&#x8BF7;&#x6C42;&#x6570;&#xFF08;&#x6709;&#x6548;+&#x7F8A;&#x6BDB;&#x515A;&#xFF09;</td>
<td></td>
<td></td>
<td>5w/s</td>
</tr>
<tr>
<td>Nginx&#x9650;&#x6D41;&#xFF0C;&#x9488;&#x5BF9;IP&#x5355;&#x4F4D;&#x65F6;&#x95F4;</td>
<td></td>
<td>10w qps</td>
<td>5w/s</td>
</tr>
<tr>
<td>Zuul&#x7F51;&#x5173;</td>
<td>&#x5E73;&#x53F0;&#x5171;&#x4EAB;&#x96C6;&#x7FA4;</td>
<td>10w qps</td>
<td></td>
</tr>
<tr>
<td>&#x8425;&#x9500;&#x670D;&#x52A1;&#x96C6;&#x7FA4;&#xFF08;&#x91CD;&#x4E1A;&#x52A1;&#xFF09;</td>
<td>10&#x8282;&#x70B9; 4&#x6838;&#x5355;&#x70B9;32G&#x5185;&#x5B58; &#x5355;&#x70B9;&#x8DD1;3&#x4E2A;&#x670D;&#x52A1;</td>
<td>&#x5355;&#x70B9;300qps&#x96C6;&#x7FA4;3k qps</td>
<td></td>
</tr>
<tr>
<td>&#x8425;&#x9500;&#x670D;&#x52A1;&#x96C6;&#x7FA4;&#xFF08;&#x8F7B;&#x4E1A;&#x52A1;&#xFF09;</td>
<td>10&#x8282;&#x70B9; 4&#x6838;&#x5355;&#x70B9;32G&#x5185;&#x5B58; &#x5355;&#x70B9;&#x8DD1;3&#x4E2A;&#x670D;&#x52A1;</td>
<td>&#x5355;&#x70B9;1200kqps&#x96C6;&#x7FA4;1.2w</td>
<td></td>
</tr>
<tr>
<td>Redis Cluster</td>
<td>6&#x4E3B;6&#x4ECE; 4&#x6838;&#x5355;&#x70B9;32G&#x5185;&#x5B58; &#x4E1A;&#x52A1;&#x7EBF;&#x72EC;&#x5360;</td>
<td>60w qps</td>
<td></td>
</tr>
<tr>
<td>mysql</td>
<td>64G&#x5185;&#x5B58; HDD &#x5355;&#x8868;1&#x5343;&#x4E07;+&#x6570;&#x636E;&#x3001;AP&#x7CFB;&#x7EDF;&#x8BFB;&#x5199;&#x5206;&#x79BB;</td>
<td>2000 <strong>tps</strong></td>
<td></td>
</tr>
<tr>
<td>mysql</td>
<td>64G&#x5185;&#x5B58; HDD &#x5206;&#x5E93;&#x5206;&#x8868; 1&#x5343;&#x4E07;+&#x6570;&#x636E;&#x3001;AP&#x7CFB;&#x7EDF;&#x8BFB;&#x5199;&#x5206;&#x79BB;</td>
<td>&#x53EF;&#x8FBE;7000 <strong>tps</strong></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>&#x5408;&#x4F5C;&#x5F15;&#x6D41;&#x4E1A;&#x52A1;</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x5C0F;&#x9EC4;&#x8F66;</td>
<td></td>
</tr>
<tr>
<td>QQ&#x7A7A;&#x95F4;</td>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</tbody>
</table>
<p>PP&#x65E5;&#x5747;&#x767B;&#x5F55;&#x91CF;7-10w&#x4E4B;&#x95F4;&#xFF0C;&#x8003;&#x8651;App JWT&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x95EE;&#x9898;&#xFF0C;&#x800C;App&#x5360;&#x6BD4;&#x8FBE;&#x5230;91%&#xFF0C;&#x5B9E;&#x9645;UV&#x662F;&#x767B;&#x5F55;&#x4E8B;&#x4EF6;2&#x500D;</p>
<p>&#x7EA6;14-20w</p>
<p>&#x8425;&#x9500;&#x4E1A;&#x52A1;PV &#xFF1A;UV = 4&#xFF1A;1 </p>
<p>&#x8425;&#x9500;PV&#xFF1A;40-80w&#x4E4B;&#x95F4;</p>
<p>&#x5B9E;&#x9645;PV&#xFF08;&#x5904;&#x7406;&#x8BF7;&#x6C42;&#x6570;&#xFF09; &#xFF1A; &#x4E1A;&#x52A1;PV = 3&#xFF1A;1</p>
<p>&#x6570;&#x636E;&#xFF1A;120-240w&#x4E4B;&#x95F4;</p>
<p>&#x5E38;&#x89C4;&#x4E1A;&#x52A1;&#xFF1A;<code>(2000000 * 0.8) / (86400 *0.2) = 92 (qps)</code></p>
<p>&#x5E38;&#x89C4;&#x62A2;&#x8D2D;&#x4E1A;&#x52A1;&#xFF08;0&#x5143;&#x8D2D;&#x3001;&#x62BD;&#x5956;&#x3001;&#x7279;&#x6743;&#x6807;&#xFF09;</p>
<p>10w / 5s = 2w qps</p>
<p>&#x5982;&#x4F55;&#x6D88;&#x5316;2w qps</p>
<p>Nginx&#x3001;Redis Cluster&#xFF08;6&#x4E3B;6&#x4ECE;&#xFF0C;&#x8425;&#x9500;&#x4E1A;&#x52A1;&#x72EC;&#x5360;&#x96C6;&#x7FA4;&#xFF09;&#x6D88;&#x5316;2w qps&#x4E0D;&#x662F;&#x95EE;&#x9898;</p>
<p>Zuul&#x7F51;&#x5173;&#x670D;&#x52A1;&#xFF08;&#x6574;&#x4E2A;&#x5E73;&#x53F0;&#x5171;&#x4EAB;&#xFF09;&#x4E1A;&#x52A1;&#x7B80;&#x5355;&#xFF0C;&#x5355;&#x7EAF;&#x6821;&#x9A8C;JWT&#x4E0E;web cookie&#xFF0C;&#x96C6;&#x7FA4;&#x6297;2w qps&#x4E0D;&#x662F;&#x95EE;&#x9898;</p>
<p>&#x8425;&#x9500;&#x670D;&#x52A1;&#x96C6;&#x7FA4;&#xFF0C;&#x5E38;&#x89C4;&#x4E1A;&#x52A1;&#x5355;&#x70B9;&#x7EA6;1.2k qps&#xFF0C;10&#x4E2A;&#x8282;&#x70B9;&#xFF0C;&#x5904;&#x7406;&#x80FD;&#x529B;1.2w qps</p>
<p>&#x590D;&#x6742;&#x4E1A;&#x52A1;&#x5982;&#x96F6;&#x5143;&#x8D2D;&#x53EA;&#x6709;300qps</p>
<p>mysql 5.6&#x3001;&#x673A;&#x68B0;&#x786C;&#x76D8;&#x3001;rc&#x4E8B;&#x52A1;&#x7EA7;&#x522B;&#x3001;&#x65E0;&#x7279;&#x6B8A;&#x7D22;&#x5F15;&#x3001;&#x5199;&#x5165;&#x6027;&#x80FD;&#x7EA6;1w qps</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; tgor.top 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-04-23 15:32:53
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../category/java并发.html" class="navigation navigation-prev " aria-label="Previous page: Java并发">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Java并发.html#锁" class="navigation navigation-next " aria-label="Next page: Java并发之锁设计">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Java并发","level":"1.4.1","depth":2,"next":{"title":"Java并发之锁设计","level":"1.4.2","depth":2,"anchor":"#锁","path":"Java-Base/Java并发.md","ref":"Java-Base/Java并发.md#锁","articles":[]},"previous":{"title":"Java并发","level":"1.4","depth":1,"path":"category/java并发.md","ref":"category/java并发.md","articles":[{"title":"Java并发","level":"1.4.1","depth":2,"path":"Java-Base/Java并发.md","ref":"Java-Base/Java并发.md","articles":[]},{"title":"Java并发之锁设计","level":"1.4.2","depth":2,"anchor":"#锁","path":"Java-Base/Java并发.md","ref":"Java-Base/Java并发.md#锁","articles":[]},{"title":"Java并发之synchronized","level":"1.4.3","depth":2,"anchor":"#synchronized","path":"Java-Base/Java并发.md","ref":"Java-Base/Java并发.md#synchronized","articles":[]},{"title":"Java Lock之ReentrantLock","level":"1.4.4","depth":2,"anchor":"#reentrantlock","path":"Java-Base/Java之Lock.md","ref":"Java-Base/Java之Lock.md#reentrantlock","articles":[]},{"title":"Java Lock之ReentrantReadWriteLock","level":"1.4.5","depth":2,"anchor":"#reentrantreadwritelock","path":"Java-Base/Java之Lock.md","ref":"Java-Base/Java之Lock.md#reentrantreadwritelock","articles":[]},{"title":"Java Future","level":"1.4.6","depth":2,"path":"Java-Base/Java之Future.md","ref":"Java-Base/Java之Future.md","articles":[]},{"title":"Java Future之FutureTask","level":"1.4.7","depth":2,"anchor":"#futuretask","path":"Java-Base/Java之Future.md","ref":"Java-Base/Java之Future.md#futuretask","articles":[]},{"title":"Java Future之CompletableFuture","level":"1.4.8","depth":2,"anchor":"#completablefuture","path":"Java-Base/Java之Future.md","ref":"Java-Base/Java之Future.md#completablefuture","articles":[]},{"title":"Java Future之ForkJoinTask","level":"1.4.9","depth":2,"anchor":"#forkjointask","path":"Java-Base/Java之Future.md","ref":"Java-Base/Java之Future.md#forkjointask","articles":[]},{"title":"Java Thread","level":"1.4.10","depth":2,"path":"Java-Base/Java之Thread.md","ref":"Java-Base/Java之Thread.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["chapter-fold","splitter","tbfed-pagefooter","page-toc-button","-search","search-pro","popup","back-to-top-button","code","copy-code-button"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy tgor.top 2019","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"fontsettings":{"theme":"sepia","family":"serif","size":1},"highlight":{},"page-toc-button":{"maxTocDepth":2,"minTocSize":2},"back-to-top-button":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"tgor","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"tgor note","gitbook":"*","description":"tgor生活工作记录"},"file":{"path":"Java-Base/Java并发.md","mtime":"2020-04-23T07:32:53.270Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-04-29T08:43:24.127Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-page-toc-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

